import 'dart:async';

import 'package:flutter_archer/data/entity/models.dart';
import 'package:flutter_archer/data/local/user/user_local_source.dart';
import 'package:flutter_archer/data/remote/user/user_remote_source.dart';
import 'package:flutter_archer/shared/services/network/http_client.dart';
import 'package:flutter_archer/shared/services/network/http_response.dart';
import 'package:flutter_archer/shared/services/persistent/persistent.dart';

class UserRepository {
  final UserRemoteSource remote;
  final UserLocalSource local;

  UserRepository(HttpClient getConnect, SpPersistentor persistentor):
        remote = UserRemoteSource(apiProvider: getConnect),local = UserLocalSource(persistentor: persistentor);

  Future<HttpResponse> login(LoginRequest data) {
    return remote.login(data);
  }

  Future<HttpResponse> register(RegisterRequest data) {
    return remote.register(data);
  }

  Future<HttpResponse> getUserInfo() {
    return remote.getUserInfo();
  }

  Future<bool> hasLogin() async{
    return local.hasToken();
  }

  Future<bool> saveToken(String token) async{
    return local.saveToken(token);
  }
}
